using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class QuestGiver : MonoBehaviour
{
    private DialogueController dialogueController;
    private QuestData_SO currentQuest;


    public DialogueData_SO  startDialogue;
    public DialogueData_SO  progressDialogue;
    public DialogueData_SO  completeDialogue;
    public DialogueData_SO  finishedDialogue;

    #region 人物状态
    public bool IsStarted
    {
        get
        {
            if (QuestManager.Instance.HaveQuest(currentQuest))
            {
                return QuestManager.Instance.GetTask(currentQuest).IsStarted;
            }
            else return false;
        }
    }
    public bool IsComplete
    {
        get
        {
            if (QuestManager.Instance.HaveQuest(currentQuest))
            {
                return QuestManager.Instance.GetTask(currentQuest).IsComplete;
            }
            else return false;
        }
    }
    public bool IsFinished
    {
        get
        {
            if (QuestManager.Instance.HaveQuest(currentQuest))
            {
                return QuestManager.Instance.GetTask(currentQuest).IsFinished;
            }
            else return false;
        }
    }
    

    #endregion
    
    private void Awake()
    {
        dialogueController = GetComponent<DialogueController>();
    }

    private void Start()
    {
        dialogueController.dialogueDataSo = startDialogue;
        currentQuest = dialogueController.dialogueDataSo.GetQuest();
    }

    private void Update()
    {
        if (IsStarted)
        {
            if (IsComplete)
            {
                dialogueController.dialogueDataSo = completeDialogue;
            }
            else
            {
                dialogueController.dialogueDataSo = progressDialogue;
            }
        }

        if (IsFinished)
        {
            dialogueController.dialogueDataSo = finishedDialogue;
        }
    }
}
